package test.ground.extension;

import com.wang.tool.extension.ExtensionFactory;
import com.wang.tool.extension.ExtensionScene;
import com.wang.tool.extension.ExtensionSelector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Random;

/**
 * @Author wangshaopeng
 * @Date 2022/5/15
 */
@Component
public class MySelector implements ExtensionSelector<ExtensionScene> {

    @Resource
    private ShaopengApi shaopengApi;

    @Resource
    private ShaopengApi2 shaopengApi2;


    @Override
    public Object selectImpl(Class<?> extensionType, ExtensionScene scene, ExtensionFactory.ExtensionLibrary extensionLibrary) {
        if (new Random().nextBoolean()) {
            return shaopengApi;
        }
        return shaopengApi2;
    }
}
